Preliminary work to compare the spatial cimis values at the cimis locations to the station’s actual reported values.
sp_cimis_raw <- read.csv('data/spatialcimis/spatial_cimis_eto_at_cimis_stations.csv')
sp_cimis_data <- sp_cimis_raw %>% gather('id','spatial_cimis_eto', 2:10)
sp_cimis_data$date <- as.Date(sp_cimis_data$date, "%d-%b-%y")
sp_cimis_data$id <- gsub('X', '', sp_cimis_data$id)
sp_cimis_data$id <- as.numeric(sp_cimis_data$id)
This assumes that you already have a local copy of ssj-weather cloned. If not get it from https://github.com/ssj-delta-cu/ssj-weather
st_name <- 'tracy'
pull_cimis_data <- function(station_name){
wy2015 <- read.csv(paste('../ssj-weather/daily_station/2015.wy/', station_name, '.csv', sep=""), stringsAsFactors = FALSE)
wy2016 <- read.csv(paste('../ssj-weather/daily_station/2016.wy/', station_name, '.csv', sep=""), stringsAsFactors = FALSE)
bothyears <- dplyr::bind_rows(wy2015, wy2016)
}
station_name_list <- c('brentwood', 'bryte', 'concord', 'davis', 'dixon', 'esparto', 'fair_oaks', 'hastings_east', 'manteca', 'modesto', 'pleasanton', 'tracy', 'twitchell_island', 'winters')
df_holder = list()
for(i in 1:length(station_name_list)){
print(station_name_list[i])
d <- pull_cimis_data(station_name_list[i])
df_holder[[i]]<-d
}
## [1] "brentwood"
## [1] "bryte"
## [1] "concord"
## [1] "davis"
## [1] "dixon"
## [1] "esparto"
## [1] "fair_oaks"
## [1] "hastings_east"
## [1] "manteca"
## [1] "modesto"
## [1] "pleasanton"
## [1] "tracy"
## [1] "twitchell_island"
## [1] "winters"
cimis_data <- dplyr::bind_rows(df_holder)
cimis_data$Date <- as.Date(cimis_data$Date)
join_df <- dplyr::inner_join(cimis_data, sp_cimis_data, by=c("Date"="date", "Station"="id"))
cimis_both_eto <- join_df %>% select(Station, Date, cimis_eto=DayEtoValue, spatial_cimis_eto)
cimis_both_eto_long <- gather(cimis_both_eto, 'Type', 'eto', 3:4)
ts <- ggplot(cimis_both_eto_long, aes(Date, eto, colour=Type, group=Type))+ geom_line()+scale_x_date()+ylab("ETO (mm/day)")+facet_wrap(~Station)
ts
cimis_both_eto_long_single <- cimis_both_eto_long %>% filter(Station == 212)
## Warning: package 'bindrcpp' was built under R version 3.3.3
ts_select <- ggplot(cimis_both_eto_long, aes(Date, eto, colour=Type, group=Type))+ geom_line()+scale_x_date()+ylab("ETO (mm/day)")
ts_select<-ggplotly(ts_select)%>%
layout(autosize = F, width = 800, height = 600)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()
ts_select
sc <- ggplot(cimis_both_eto, aes(cimis_eto, spatial_cimis_eto, colour=factor(Station), group=factor(Station)))+geom_point(alpha=0.1)+geom_smooth(method='lm', se = FALSE)
sc<-ggplotly(sc)%>%
layout(autosize = F, width = 800, height = 600)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()
sc